/**
 */
package org.xtext.mydsl.scheduler.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectResolvingEList;

import org.xtext.mydsl.scheduler.Charla;
import org.xtext.mydsl.scheduler.Orador;
import org.xtext.mydsl.scheduler.SchedulerPackage;
import org.xtext.mydsl.scheduler.Track;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Charla</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.CharlaImpl#getOradores <em>Oradores</em>}</li>
 *   <li>{@link org.xtext.mydsl.scheduler.impl.CharlaImpl#getTrack <em>Track</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class CharlaImpl extends ActividadImpl implements Charla
{
  /**
   * The cached value of the '{@link #getOradores() <em>Oradores</em>}' reference list.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getOradores()
   * @generated
   * @ordered
   */
  protected EList<Orador> oradores;

  /**
   * The cached value of the '{@link #getTrack() <em>Track</em>}' containment reference.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getTrack()
   * @generated
   * @ordered
   */
  protected Track track;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected CharlaImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return SchedulerPackage.Literals.CHARLA;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public EList<Orador> getOradores()
  {
    if (oradores == null)
    {
      oradores = new EObjectResolvingEList<Orador>(Orador.class, this, SchedulerPackage.CHARLA__ORADORES);
    }
    return oradores;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public Track getTrack()
  {
    return track;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public NotificationChain basicSetTrack(Track newTrack, NotificationChain msgs)
  {
    Track oldTrack = track;
    track = newTrack;
    if (eNotificationRequired())
    {
      ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, SchedulerPackage.CHARLA__TRACK, oldTrack, newTrack);
      if (msgs == null) msgs = notification; else msgs.add(notification);
    }
    return msgs;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setTrack(Track newTrack)
  {
    if (newTrack != track)
    {
      NotificationChain msgs = null;
      if (track != null)
        msgs = ((InternalEObject)track).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.CHARLA__TRACK, null, msgs);
      if (newTrack != null)
        msgs = ((InternalEObject)newTrack).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - SchedulerPackage.CHARLA__TRACK, null, msgs);
      msgs = basicSetTrack(newTrack, msgs);
      if (msgs != null) msgs.dispatch();
    }
    else if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, SchedulerPackage.CHARLA__TRACK, newTrack, newTrack));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs)
  {
    switch (featureID)
    {
      case SchedulerPackage.CHARLA__TRACK:
        return basicSetTrack(null, msgs);
    }
    return super.eInverseRemove(otherEnd, featureID, msgs);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case SchedulerPackage.CHARLA__ORADORES:
        return getOradores();
      case SchedulerPackage.CHARLA__TRACK:
        return getTrack();
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @SuppressWarnings("unchecked")
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case SchedulerPackage.CHARLA__ORADORES:
        getOradores().clear();
        getOradores().addAll((Collection<? extends Orador>)newValue);
        return;
      case SchedulerPackage.CHARLA__TRACK:
        setTrack((Track)newValue);
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case SchedulerPackage.CHARLA__ORADORES:
        getOradores().clear();
        return;
      case SchedulerPackage.CHARLA__TRACK:
        setTrack((Track)null);
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case SchedulerPackage.CHARLA__ORADORES:
        return oradores != null && !oradores.isEmpty();
      case SchedulerPackage.CHARLA__TRACK:
        return track != null;
    }
    return super.eIsSet(featureID);
  }

} //CharlaImpl
